#!/usr/bin/env python3
import sqlite3
import os

# 检查数据库文件
db_path = 'instance/decoration_app.db'
if os.path.exists(db_path):
    print(f"✅ 数据库文件存在: {db_path}")
    
    # 连接数据库
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    
    # 查询所有表
    cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
    tables = cursor.fetchall()
    
    print(f"\n📊 数据库中的表 ({len(tables)} 个):")
    for table in tables:
        table_name = table[0]
        print(f"  - {table_name}")
        
        # 查询表结构
        cursor.execute(f"PRAGMA table_info({table_name});")
        columns = cursor.fetchall()
        print(f"    列: {[col[1] for col in columns]}")
        
        # 查询记录数
        cursor.execute(f"SELECT COUNT(*) FROM {table_name};")
        count = cursor.fetchone()[0]
        print(f"    记录数: {count}")
        print()
    
    conn.close()
else:
    print(f"❌ 数据库文件不存在: {db_path}")
    print("需要创建数据库...")
